package j.framework.tags.easyui;

import javax.servlet.jsp.JspException;
import java.util.Map;

/**
 * easyui 之 数字框，此标签与textbox类似
 * Created by junhai on 2015/1/17.
 */
public class NumberBoxTag extends TextBoxTag {

    private Double min;
    private Double max;
    private Integer precision;//若为null，则不设置此项，按easyui的标准格式

    @Override
    public void writeEasyuiDataOptions(Map<String, Object> dataOptions) throws JspException {
        super.writeEasyuiDataOptions(dataOptions);
        if(min!=null){
            dataOptions.put("min",min);
        }
        if(max!=null){
            dataOptions.put("max",max);
        }
        if(precision!=null && precision>=0){
            dataOptions.put("precision",precision);
        }
    }

    @Override
    protected String getControlWidth() {
        return "150px";
    }

    @Override
    public String getEasyuiClassName() {
        return "easyui-numberbox";
    }

    public void setMin(Double min) {
        this.min = min;
    }

    public void setMax(Double max) {
        this.max = max;
    }

    public void setPrecision(int precision) {
        this.precision = precision;
    }
}
